function GET_QQBUDX(id) {
    $("#Up_LoginQrcode").html('');
    XF_QrCode_ID = 'XFPAY';
     var ii = layer.load(5, {
		shade: [0.1, '#fff']
	});
	$.ajax({
	    type: "POST",
	    url: "Ajax.php",
	    data: {
	        act:'Get_QQPCQr',
	        id: id,
	    },
	    dataType: 'json',
	    timeout: 15000,
	    success: function(res) {
	        layer.close(ii);
	        if(res.code == 200){
	            if(res.data.type == 'qqpay'){
	                Up_id = res.data.id
	                type = res.data.type;
	                beizhu = res.data.beizhu;
	                XF_QrCode_ID = 0;  
	                $('#modalHeaderColorInfo_Up_Qr_modal').modal('show');
	                XFQQPCQRCODE();
	            }else{
	                layer.msg('非法操作！', {
                        icon: 2,
                        time: 3000
                    }, function() {
                        location.reload();
                    });
	            }
	        }else{
	            layer.msg(res.msg, {
                    icon: 2,
                    time: 3000
                }, function() {
                    location.reload();
                });
	        }
	    },
	    error: function(data) {
	        layer.close(ii);
	        layer.msg('服务器错误！', {
                icon: 2,
                time: 3000
            }, function() {
                location.reload();
            });
	    }
	});
}

function XFQQPCQRCODE(){
    if(XF_QrCode_ID == 0){
        var ii = layer.load(5, {
			shade: [0.1, '#fff']
		});
		$.post("Ajax.php", {
          act: "Get_QQPCLogin_QrCode",
          id:Up_id,
          type: type,
          beizhu: beizhu
        },function(res) {
            layer.close(ii);  
            if(res.code == 200){
                XF_QrCode_ID = res.data.id;
                XF_QrCode_URL = res.data.qr_url;
                qr_id         = res.data.qr_id;
                var is_type = '"QQ"手机摄像头扫一扫';
                $("#Up_LoginQrcode_msg").html('<center>请您使用' + is_type + '->"2分钟内"扫以下码登录,扫码之后请返回此页面等待1分钟,如超过1分钟则系统登录失败,请您再次重试</center>');
                $("#Up_LoginQrcode").html('<center><img align="center" id="qrcodeimg" alt="加载中..." src="' + XF_QrCode_URL + '" title="扫码登录" width="200" height="200" style=" position: relative; border: green solid 1px;"></center>'); //输出登录二维码
                JIANCEQRCODE();
            }else{
                layer.msg(res.msg, {
                    icon: 2,
                    time: 3000
                }, function() {
                    location.reload();
                });
            }
        },"JSON");
    }
}
function JIANCEQRCODE(){
    var Up_QrCode_cookie = 0;
    if (XF_QrCode_ID != 0 && Up_QrCode_cookie == 0) {
        $.post("Ajax.php", {
            act: "GET_JIANCE",
            type: type,
            qr_id: Up_id
        }, function(data){
            if(data.code == '1'){
                XF_QrCode_ID = 1;
                Up_QrCode_cookie = 1;
                var ii =   layer.msg('正在获取 cookie 中，请稍等...', {
                  icon: 16,
                  shade: 0.3,
                  time: 0
                });
                 setTimeout(function() {
                     $.ajax({
                         type: "POST",
                         url: "Ajax.php",
                         data: {
                              'act': 'Get_QQPCCOOKIE',
                              id: Up_id,
                              beizhu: beizhu
                          },
                         dataType: 'json',
                         timeout: 15000,
                         success: function(xfdata) {
                             layer.close(ii);
                             if (xfdata.code == 200){
                                 layer.msg(xfdata.msg, {
                                    icon: 1,
                                    time: 3000
                                }, function() {
                                    location.reload();
                                });
                             }else{
                                 layer.msg(xfdata.msg, {
                                    icon: 2,
                                    time: 3000
                                }, function() {
                                    location.reload();
                                });
                             }
                         },
                         error: function(xfdata) {
                              layer.close(ii);
                              layer.msg('操作失败,服务器错误');
                         }
                     });
                 }, 5000);
            }else if (data.code == '-1'){
                layer.msg(data.msg, {
                    icon: 2,
                    time: 3000
                }, function() {
                    location.reload();
                });
            }else if(data.code == '6'){
                startTime = Date.now();
                timeout = 120000; // 超时时间为120秒
                delay = 1000; // 延迟时间为1秒
                // 开始循环查询
                checkStatus();
            }
        }, "JSON");  
    }
}

// 定义循环查询函数
function checkStatus() {
    $.post("Ajax.php",{
        act: "GET_JIANCE",
        type: type,
        qr_id: Up_id
    }, function(response){
        if (response.code == '1'){
            XF_QrCode_ID = 1;
            Up_QrCode_cookie = 1;
            var ii =   layer.msg('正在获取 cookie 中，请稍等...', {
                  icon: 16,
                  shade: 0.3,
                  time: 0
                }); 
            setTimeout(function(){
                $.ajax({
                    type: "POST",
                    url: "Ajax.php",
                    data: {
                        'act': 'Get_QQPCCOOKIE',
                        id: Up_id,
                        beizhu: beizhu
                    },
                    dataType: 'json',
                    timeout: 15000,
                    success: function(xfdata) {
                        layer.close(ii);
                        if (xfdata.code == 200){
                            layer.msg(xfdata.msg, {
                                icon: 1,
                                time: 3000
                            }, function() {
                                location.reload();
                            });
                        }else{
                            layer.msg(xfdata.msg, {
                                icon: 2,
                                time: 3000
                            }, function() {
                                location.reload();
                            });
                        }
                    },
                    error: function(xfdata) {
                          layer.close(ii);
                          layer.msg('操作失败,服务器错误');
                     }
                });
            }, 5000);// 延时5秒请求
        }else if (response.code == '6'){
            var currentTime = Date.now();
             if (currentTime - startTime < timeout){
                 // 未超时，延迟一定时间后继续循环查询
                 setTimeout(checkStatus, delay);
             }else{
                 layer.msg('超时无响应，请重新更新扫码', {
                        icon: 2,
                        time: 3000
                    }, function() {
                        location.reload();
                    });
             }
        }else if(response.code == '4'){
            layer.msg('二维码已失效，请重新更新', {
                    icon: 2,
                    time: 3000
                }, function() {
                    location.reload();
                });
        }
    }, "JSON");
}